﻿@model StudentCreateViewModel
@inject IStudentRepository _istudentRepository
@{
    Layout = "_Layout";
    ViewBag.Title = "创建学生信息";
}

<form enctype="multipart/form-data" asp-controller="home" asp-action="creat" method="post" class="mt-3">

    <div asp-validation-summary="All" class="text-danger"></div>

    <div class="form-group row " style="margin-bottom: 15px;">
            <label asp-for="Name" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-10">
                    <input asp-for="Name" class="form-control" placeholder="Name"/>
            <span asp-validation-for="Name" class="text-danger"></span>
            </div>
      </div>
    <div class="form-group row " style="margin-bottom: 15px;">
            <label asp-for="EmailAddress" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-10">
            <input asp-for="EmailAddress" class="form-control" placeholder="EmailAddress" />
            <span asp-validation-for="EmailAddress" class="text-danger"></span>
            </div>
      </div>

    <div class="form-group row " style="margin-bottom: 15px;">
        <label asp-for="ClassName" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
            <input asp-for="ClassName" class="form-control" placeholder="ClassName" />
            <span asp-validation-for="ClassName" class="text-danger"></span>
        </div>
      </div>

    <div class="form-group row " style="margin-bottom: 15px;">
            <label asp-for="Photos" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-10">
                <div class="custom-file">
                <input asp-for="Photos" multiple class="form-control custom-file-input"/>
                </div>
            </div>
        </div>

    <div class="form-group row " style="margin-bottom: 15px;">
            <label asp-for="Major" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-10">
                <select asp-for="Major"
                        class="custom-select mr-sm-2"
                        asp-items="Html.GetEnumSelectList<MajorEnum>()">
                    <option value=""> 请选择</option>
                </select>
                <span asp-validation-for="Major" class="text-danger"></span>
            </div>
        </div>

    <div class="form-group row " style="margin-bottom: 15px;">
        <div class="col-sm-10">
          <button type="submit" class="btn btn-primary" asp-controller="home" asp-action="creat">创建</button>
        </div>
      </div>

    <div class="form-group row " style="margin-bottom: 5px;">
          <div class="col-sm-10">
            学生人数总数 = @_istudentRepository.GetAllStudents().Count().ToString();
          </div>
      </div>
    
</form>

@section Scripts {
    <script>
        // $(document).ready(function () {
        //     $(".custom-file-input").on("change", function () {
        //         //console.log($(this));
        //         var fileLabel = $(this).next(".custom-file-label");
        //         var files = $(this)[0].files;
        //         if (files.length > 1) {
        //             fileLabel.html("您已经选择了：" + files.length + " 个文件");
        //         } else if (files.length == 1) {
        //             fileLabel.html(files[0].name);
        //         }
        //     });
        // }); 以上是在选择多张图片的时候，input文本框中显示 提示。。不过以上操作在bootsctrap中已经帮我们做好了
    </script>
}